<script setup>
import { GetWorkShopService } from '@/api/clothrequest'
import { ref } from 'vue'
import { useParms } from '@/stores'
defineProps({
  modelValue: {
    type: [Number, String]
  },
  width: {
    type: String
  }
})
const params = ref({
  factoryId: '', //产房号
  id: '', //车间号
  checkStartDate: '', //搜索开始时间
  checkEndDate: '', //搜索结束时间
  deviceCode: '', //机台号
  clothCode: '' //布匹编号
})
const useparams = useParms()
const emit = defineEmits(['update:modelValue'])
const workShopList = ref([])
const getMathineList = async () => {
  params.value.factoryId = useparams.params.factoryId
  params.value.id = useparams.params.id
  params.value.checkStartDate = useparams.params.checkStartDate
  params.value.checkStartDate = useparams.params.checkStartDate
  params.value.deviceCode = useparams.params.deviceCode
  params.value.clothCode = useparams.params.clothCode
  const res = await GetWorkShopService(params.value)
  workShopList.value = res.data.data
}
getMathineList()
const changeWorkShop = ($event) => {
  useparams.params.id = $event.toString()
  console.log(useparams.params.id)
}
// { value: 5, name: '双抽针' },
//   { value: 100, name: '孔洞' },
//   { value: 0, name: '纵向' },
//   { value: 100, name: '斑点' },
//   { value: 880, name: '针路' },
//   { value: 440, name: '掉布' },
//   { value: 100, name: '不规则' },
//   { value: 400, name: '漏针' },
//   { value: 2310, name: '烂针' },
//   { value: 1450, name: '线疵' },
//   { value: 122, name: '横向' }
// { value: '双抽针' },
//       { value: '孔洞' },
//       { value: '纵向' },
//       { value: '斑点' },
//       { value: '针路' },
//       { value: '掉布' },
//       { value: '不规则' },
//       { value: '漏针' },
//       { value: '烂针' },
//       { value: '线疵' },
//       { value: '横向' }
</script>

<template>
  <!-- label 展示给用户看的，value 收集起来提交给后台的 -->
  <el-select
    :modelValue="modelValue"
    @update:modelValue="emit('update:modelValue', $event)"
    @change="changeWorkShop($event)"
    :style="{ width }"
    @click="getMathineList()"
  >
    <el-option
      v-for="(item, index) in workShopList"
      :key="index"
      :label="item.name"
      :value="item.id.toString()"
    ></el-option>
  </el-select>
</template>
